home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / What's New? / Software Development Kits / Mac OS USB DDK / MacOS USB DDK 1.0b4 / NeptuneDDK / Examples / MouseModule / MouseModuleHeader.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-26  |  3.8 KB  |  121 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        MouseModuleHeader.c
  3.  
  4.     Contains:    Mouse Module Header file
  5.  
  6.     Version:    xxx put version here xxx
  7.  
  8.     Copyright:    © 1997-1998 by Apple Computer, Inc., all rights reserved.
  9.  
  10. */
  11.  
  12. #include <Types.h>
  13. #include <Devices.h>
  14. #include <DriverServices.h>
  15. #include <USB.h>
  16.  
  17.  
  18. #include "MouseModule.h"
  19. #include "MouseModuleVersion.h"
  20.  
  21. static     OSStatus     MouseModuleInitialize (USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
  22. static     OSStatus     MouseModuleFinalize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc);
  23. static     OSStatus     MouseInterfaceInitialize (UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device);
  24.  
  25. extern    usbMousePBStruct myMousePB;
  26.  
  27. //------------------------------------------------------
  28. //
  29. //    This is the driver description structure that the expert looks for first.
  30. //  If it's here, the information within is used to match the driver
  31. //  to the device whose descriptor was passed to the expert.
  32. //    Information in this block is also used by the expert when an
  33. //  entry is created in the Name Registry.
  34. //
  35. //------------------------------------------------------
  36. USBDriverDescription    TheUSBDriverDescription = 
  37. {
  38.     // Signature info
  39.     kTheUSBDriverDescriptionSignature,
  40.     kInitialUSBDriverDescriptor,
  41.     
  42.     // Device Info
  43.     0,                                        // vendor = not device specific
  44.     0,                                        // product = not device specific
  45.     0,                                        // version of product = not device specific
  46.     kUSBMouseInterfaceProtocol,                // protocol = not device specific
  47.     
  48.     // Interface Info    (* I don't think this would always be required...*)                
  49.     0,                                        // Configuration Value
  50.     0,                                        // Interface Number
  51.     kUSBHIDInterfaceClass,                    // Interface Class
  52.     kUSBBootInterfaceSubClass,                 // Interface SubClass
  53.     kUSBMouseInterfaceProtocol,                // Interface Protocol
  54.         
  55.     
  56.     // Driver Info
  57.     "\pUSBHIDMouseModule",                        // Driver name for Name Registry
  58.     kUSBHIDInterfaceClass,                    // Device Class  (from USBDeviceDefines.h)
  59.     kUSBBootInterfaceSubClass,                // Device Subclass 
  60.     kMouseHexMajorVers, 
  61.     kMouseHexMinorVers, 
  62.     kMouseCurrentRelease, 
  63.     kMouseReleaseStage,                        // version of driver
  64.     
  65.     // Driver Loading Info
  66.     kUSBProtocolMustMatch                    // Flags (currently undefined)
  67. };
  68.  
  69. USBClassDriverPluginDispatchTable TheClassDriverPluginDispatchTable =
  70. {
  71.     kClassDriverPluginVersion,                // Version of this structure
  72.     0,                                        // Hardware Validation Procedure
  73.     MouseModuleInitialize,                    // Initialization Procedure
  74.     MouseInterfaceInitialize,                // Interface Initialization Procedure
  75.     MouseModuleFinalize,                    // Finalization Procedure
  76.     0,                                        // Driver Notification Procedure
  77. };
  78.     
  79.  
  80.     
  81. // Initialization function
  82. // Called upon load by Expert
  83. static     OSStatus     MouseModuleInitialize (USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable)
  84. {
  85. #pragma unused (busPowerAvailable)
  86.     DriverEntry(device, pDesc);
  87.     return (OSStatus)noErr;
  88. }
  89.  
  90. // Interface Initialization Initialization function
  91. // Called upon load by Expert
  92. static     OSStatus     MouseInterfaceInitialize (UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device)
  93. {
  94.     InterfaceEntry(interfacenum, pInterface, pDesc, device);
  95.     return (OSStatus)noErr;
  96. }
  97.  
  98.  
  99.  
  100. // Termination function
  101. // Called by Expert when driver is being shut down
  102. static OSStatus MouseModuleFinalize(USBDeviceRef theDeviceRef, USBDeviceDescriptorPtr pDesc)
  103. {
  104. #pragma unused (pDesc)
  105. OSStatus myErr;
  106.  
  107.     if (myMousePB.pFullConfigDescriptor != nil)
  108.     {
  109.         myMousePB.pb.usbReference = theDeviceRef;
  110.         myMousePB.pb.pbVersion = kUSBCurrentPBVersion;
  111.         myMousePB.pb.usbFlags = 0;
  112.         myMousePB.pb.usbRefcon = 0;             
  113.         myMousePB.pb.usbBuffer = myMousePB.pFullConfigDescriptor;        
  114.         myMousePB.pb.usbCompletion = (USBCompletion)-1;
  115.         
  116.         myErr = USBDeallocMem(&myMousePB.pb);
  117.     };
  118.     return (OSStatus)noErr;
  119. }
  120.  
  121.